﻿using System.IO;
using System.Linq;
using HeritageAcademy.Models.DataModels;
using HeritageAcademy.Shared;

namespace HeritageAcademy.Models.Loaders
{
    public class UsersConfigLoader : LoaderBase<Users>
    {
        public UsersConfigLoader(Users users) : base(users)
        {
            Initialize
                (
                Path.Combine(IOHelper.CommonMetaDataFolder, Shared.Properties.Resources.Application_Config),
                "users.conf"
                );
        }

        public User ActiveUser
        {
            get
            {
                object usr = null;
                foreach (var t in Model.User.Where(t => t.Active == "true"))
                    usr = t;
                return (User)usr;               
            }
        }
    }
}